package com.jlib.util;


/**
 * This is a String utility to be easy to manipulate String
 * @author Dong Han
 * @since 1.0
 * @version 1.0
 *
 */
public class StringUtil {
	
	public static final String EMPTY_STRING = "";
	
	/**
	 * determine a string whether it equals a empty string " "
	 * @param str
	 * @return
	 */
	public static boolean isEmpty(String str){
		return EMPTY_STRING.equals(str);
	}
	/**
	 * determine a string whether it don't equals a empty string " "
	 * @param str
	 * @return
	 */
	public static boolean isNotEmpty(String str){
		return !isEmpty(str);
	}
	/**
	 * get the length of a string without the space char
	 * @param str
	 * @return
	 */
	public static int getNoneLeerCharLength(String str){
		int length = str.length();
		for(int i = 0; i < str.length(); i++){
			if(str.charAt(i) == ' ')
				length--;
		}
		return length;
	}
	/**
	 * get the length of a string without the space chars before and after it
	 * @param str
	 * @return
	 */
	public static int getTrimLength(String str){
		return str.trim().length();
	}
	/**
	 * determine whether a string is empty string without space chars before and after it
	 * @param str
	 * @return
	 */
	public static boolean isTrimEmpty(String str){
		return EMPTY_STRING.equals(str.trim());
	}
	/**
	 * determine whether a string is not a empty string without space chars before and after it
	 * @param str
	 * @return
	 */
	public static boolean isNotTrimEmpty(String str){
		return !isTrimEmpty(str);
	}

}
